﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.GrippedObjectList.CApSetGripppedObjectsUtils
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using System.Collections.ObjectModel;
using Tecnomatix.Engineering;
using Tecnomatix.Planning;


namespace DnProcessSimulateCommands.GrippedObjectList;

internal static class CApSetGripppedObjectsUtils
{
  public static ITxPlanningObject GetPlanningRepresentation(ITxObject obj)
  {
    switch (obj)
    {
      case ITxProcessModelObject processModelObject:
        pattern_0 = processModelObject.PlanningRepresentation;
        break;
    }
    return pattern_0;
  }

  public static ITxPlanningObject GetPlanningPart(ITxObject pickedObject)
  {
    return !(pickedObject is TxPartAppearance) ? CApSetGripppedObjectsUtils.GetPlanningRepresentation(pickedObject) : (pickedObject as TxPartAppearance).OriginPart;
  }

  public static TxGripper GetGripperFromSelection()
  {
    TxObjectList allItems = TxApplication.ActiveSelection.GetAllItems();
    return ((Collection<ITxObject>) allItems).Count != 1 ? (TxGripper) null : ((Collection<ITxObject>) allItems)[0] as TxGripper;
  }

  public static bool IsValidObjectForUI(ITxObject obj)
  {
    bool flag = false;
    if (CApSetGripppedObjectsUtils.GetObjectName(obj) != null)
      flag = true;
    return flag;
  }

  public static string GetObjectName(ITxObject obj)
  {
    string objectName;
    if (obj is ITxPlanningObject)
    {
      ITxPlanningObject itxPlanningObject = obj as ITxPlanningObject;
      if (itxPlanningObject.IsObjectLoaded())
      {
        objectName = obj.Name;
      }
      else
      {
        TxPlanningObjectEx planningObjectEx = new TxPlanningObjectEx(itxPlanningObject);
        try
        {
          objectName = planningObjectEx.Name;
        }
        catch (TxException ex)
        {
          objectName = (string) null;
        }
      }
    }
    else
      objectName = obj.Name;
    return objectName;
  }
}
